<%--
  Created by IntelliJ IDEA.
  User: jia19
  Date: 2015/9/28
  Time: 10:12
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<html>
<head>
    <meta charset="UTF-8"/>
    <title>网络购书系统——登录</title>
    <%@ include file="../layout/import.jsp"%>
    <script type="text/javascript">
        function submit() {
            $.ajax({
                url: "/doneLogin.do",
                data: $('#loginForm').serialize(),
                method: "POST",
                dataType: "json",
                error: function () {
                    alert("表单提交出错，请稍后再试");
                },
                success: function(response) {
                    if(response.code == 0) {
                        window.location.href = "/index.do";

                    }
                    else {
                        alert(response.description);
                    }
                }
            });
        }
    </script>
</head>
<body>
<%@include file="nav.jsp"%>
<div class="container" style="min-height: 75%">
    <div class="col-md-12">
        <div class="col-md-offset-4 col-md-4">
            <div class="text-center"><h3>登录</h3></div>
        </div>
        <br /><br />
        <div class="col-md-4 col-md-offset-4">
            <form class="form-horizontal" role="form" method="post" id="loginForm">
                <div class="form-group">
                    <label for="username" class="col-sm-4 control-label">请输入用户名</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" id="username" placeholder="请输入您的用户名" name="username">
                    </div>
                </div>
                <div class="form-group">
                    <label for="password" class="col-sm-4 control-label">请输入密码</label>
                    <div class="col-sm-8">
                        <input type="password" class="form-control" id="password" placeholder="请输入登录密码" name="password">
                    </div>
                </div>
                <div class="form-horizontal">
                    <div class="text-center">
                        <a class="btn btn-large btn-primary text-center" onclick="submit()">登录</a>

                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<%@include file="footer.jsp"%>
</body>
</html>
